<template>
    <div>
        <h1>显示</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td><input type="checkbox" v-model="checked" @click="checkedAll"></td>
                    <td>Id</td>
                    <td>账号</td>
                    <td>姓名</td>
                    <td>联系方式</td>
                    <td>上传头像</td>
                    <td>角色</td>
                </tr>

                <tr v-for="itme in data.list" :key="itme.Id">
                    <td><input type="checkbox" v-model="ids" :value="itme.Id" @change="checkedOne"></td>
                    <td>{{ itme.Id }}</td>
                    <td>{{ itme.AdminName }}</td>
                    <td>{{ itme.UserName }}</td>
                    <td>{{ itme.Tel }}</td>
                    <td> <img :src="itme.Pic" width="100" height="100"></td>
                    <td>{{ itme.RoleName }}</td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import axios from 'axios';
import { useStore } from '@/stores/user'
import { useRouter } from 'vue-router';
const router = useRouter();
const abc = useStore();
let info: any = reactive({
    pageIndex: 1,
    pagesize: 2
})
let data: any = reactive({
    list: [],
    totalcount: 0,
    totalpage: 0
})
let checked: any = ref(false);
let ids: any = ref([]);
onMounted(() => {
    // if (abc.UserIndo.Id) {

    // }
    // else {
    //     router.push('/login')
    // }
    getlist();
})
const getlist = () => {
    axios({
        url: '/api/Memder/Showdto',
        method: 'get',
        params: info
    })
        .then((res) => {
            console.log(res);
            Object.assign(data, res.data);
        })
}
//反选
const checkedOne = () => {
    if (ids.value.length = data.list.length) {
        checked.value = true;
    }
    else {
        checked.value = false;
    }
}
//全选全不选
const checkedAll = () => {
    checked.value = !checked.value
    if (checked.value == true) {
        ids.value = data.list.map((itme: any) => {
            return itme.Id;
        });

    }
    else {
        ids.value = [];
    }
}



const Del = (id: any) => {

}


</script>

<style scoped></style>